package com.example.dishit.controller.friendmaint;

import java.util.ArrayList;
import java.util.List;

import com.example.dishit.view.friendmaint.FriendMaintActivity;

public class FriendMaintController implements IFriendMaintController {
    private static final FriendMaintController instance = new FriendMaintController();
    private FriendMaintActivity view;
    private final List<String> selectedUserIds = new ArrayList<String>();
    
    private FriendMaintController() {}
    
    public static FriendMaintController instance() { return instance; }
    
    public void setView(final FriendMaintActivity view) { this.view = view; }
    
    public void cancel() { view.finish(); }
    
    public void addSelection(String disher)    { selectedUserIds.add(disher); }
    public void removeSelection(String disher) { selectedUserIds.remove(disher); }
    public void clearSelections()              { selectedUserIds.clear(); }
    
    public List<String> getSelectionsSnapshot() {
        final List<String> current = selectedUserIds;
        final List<String> snapshot = new ArrayList<String>();
        for(final String s : current) snapshot.add(s);
        return snapshot;
    }
}
